#ifndef __STDMYSQL_H_
#define __STDMYSQL_H_

#include <string>
#include <vector>
#include <memory>
#define MYSQLPOOL StdMysqlPool::GlobalInstance()

using CStrRef = const std::string&;
using StrArray = std::vector<std::string>;

struct stdSqlPrivate;

class stdMysql
{
public:
    stdMysql();
    ~stdMysql();
    bool Connect(CStrRef host, CStrRef user, CStrRef passwd, CStrRef databaseName,int port);
    bool isConnected();
    bool Execute(CStrRef sql);
    std::vector<StrArray> GetTableInfo(CStrRef sql);
    bool ExecuteTransaction(const StrArray& sqlVec);
   
private:
    stdSqlPrivate *p;
};

using MysqlPtr = std::shared_ptr<stdMysql>;
struct StdMysqlPoolPrivate;
class StdMysqlPool
{
public:
    static StdMysqlPool* GlobalInstance();
    ~StdMysqlPool();
    bool SetParams(int MaxCount, CStrRef host, CStrRef user, CStrRef passwd, CStrRef databaseName, unsigned int port);
    MysqlPtr GetMysql();
    void CloseMysql(MysqlPtr ptr);

private:
    StdMysqlPool();
    StdMysqlPoolPrivate *p;
};

#endif//__STDMYSQL_H_